/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package edu.webbapps.cormac_susilo.fit;

import com.sun.jersey.multipart.FormDataParam;
import edu.webbapps.cormac_susilo.core.Frame;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;
import javax.ws.rs.Consumes;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.GenericEntity;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;

/**
 * TODO this should not remain as a REST resource, we probably want to 
 * create a servlet or something similar instead
 * @author tor
 */
@Deprecated
@Path("upload")
public class FileReceiver {

    @POST
    @Consumes(MediaType.MULTIPART_FORM_DATA)
    @Produces(MediaType.APPLICATION_JSON)
    public Response uploadFile(@FormDataParam("datafile") InputStream uploadedInputStream) {
        /*
        List<Frame> list = CormacFitDecoder.convertFile(uploadedInputStream);
        List<RecordMesgWrapper> xlist = new ArrayList<RecordMesgWrapper>(list.size());
        for (Frame mesg : list) {
            // TODO conver to Frame Class before persisting
            //xlist.add(new FrameWrapper(mesg));
        }

        GenericEntity<List<RecordMesgWrapper>> ge = new GenericEntity<List<RecordMesgWrapper>>(xlist) {
        };
        */
        return Response.ok().build();
    }
}
